<?php
/*
 * sfPrototypeWindowHelpers
 * Helpers for the sfPrototypeWindowsPlugin. They are placed here inside a class
 * to reduce the possibility of naming conflicts with functions that could potentially be of the same name
 */
class sfPrototypeWindowHelpers
{
  /*
   * sfPrototypeWindowHelpers::LoadRequiredFiles
   * Loads the necessary files for link_to_prototype_dialog() and link_to_prototype_window() hepers. 
   * May be useful when the dialogue being created directly in JS so the link_to_prototype_XXX()  heloer
   * is not called;
   * @author Yining Zhao
   * @param string  $theme Defines the name of the theme. It uses default theme by default  
   */
  static function LoadRequiredFiles($theme = 'alphacube')
  {
    $request = sfContext::getInstance()->getResponse();
    $request->addJavascript(sfConfig::get('sf_prototype_web_dir').'/js/prototype');
    $request->addJavascript(sfConfig::get('sf_prototype_web_dir').'/js/scriptaculous');
    $request->addJavascript(sfConfig::get('sf_prototype_web_dir').'/js/effects');
    $request->addJavascript(sfConfig::get('sf_prototype_window_web_dir').'/js/window');
    $request->addJavascript(sfConfig::get('sf_prototype_window_web_dir').'/js/window_ext');
    sfPrototypeWindowHelpers::LoadThemeFiles($theme);

    if(sfConfig::get('sf_debug'))
    {
      $request->addJavascript(sfConfig::get('sf_prototype_window_web_dir').'/js/debug');
      $request->addJavascript(sfConfig::get('sf_prototype_window_web_dir').'/js/extended_debug');
    }
  }
  /*
   * LoadThemeFiles
   * Loads the files necessary for a particular theme
   * @author Yining Zhao
   * @param string $theme name of the theme, e.g. alphacube
   */
  static function LoadThemeFiles($theme)
  {
  	sfContext::getInstance()->getResponse()
  	 ->addStylesheet(sfConfig::get('sf_prototype_window_web_dir').'/themes/default');
  	sfContext::getInstance()->getResponse()
  	 ->addStylesheet(sfConfig::get('sf_prototype_window_web_dir').'/themes/'.$theme);
  }
}
?>